package com.colliery.model;

import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;

/**
 * @PACKAGE_NAME: com.ziicoo.askface.utils
 * @NAME: HttpsUtils
 * @USER: NIHUI
 * @DATE: 2021/11/5
 * @PROJECT_NAME: support-askface
 **/
public class BrushTestUtils {


    public String sendPost(){
        try {
            String postURL  = "https://duli.zsztx.cn/admin/index.php?act=questionlist";
            PostMethod postMethod = null;
            postMethod = new PostMethod(postURL) ;
            //postMethod.setRequestHeader("Accept", "text/plain;charset=GBK") ;
            //参数设置，需要注意的就是里边不能传NULL，要传空字符串
            NameValuePair[] data = {
                    new NameValuePair("page","3"),
                    new NameValuePair("pagesize","10"),
                    new NameValuePair("typeid","1")

            };
            //json格式的参数解析
           // postMethod.setRequestHeader("Accept", "text/plain;charset=utf-8");

            postMethod.setRequestBody(data);
            org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
            httpClient.getParams().setContentCharset("UTF-8");
            int response = httpClient.executeMethod(postMethod); // 执行POST方法
           postMethod.getParams().setContentCharset("UTF-8");
            //String result = postMethod.getResponseBodyAsString() ;
            String result = new String(postMethod.getResponseBodyAsString().getBytes(), "UTF-8");
            return result;
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }
}

